-- STANDARD SCRIPT
-- IT UPDATES THE batch_status_insurance2_t TABLE SHOWING THE BATCH IS DONE;
--

\set ON_ERROR_STOP 1
CREATE OR REPLACE FUNCTION batch_done_insurance2_f() RETURNS void AS $$
DECLARE
  v_batch_run_date timestamp;
  v_cust_id integer;
BEGIN


  -- obtain current batch date
  SELECT INTO v_batch_run_date our_run_date FROM batch_insurance2_t LIMIT 1;
  SELECT INTO v_cust_id cust_id from batch_insurance2_t limit 1;

  PERFORM ml_upd_batch_status_insurance2_new_f(v_cust_id,v_batch_run_date,3,0,'BATCH DONE');

  RETURN;

END;
$$ LANGUAGE plpgsql;

-- call the batch done procedure here itself along with the store procedure
-- loading as this is the last step
SELECT batch_done_insurance2_f();

